﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.Skins;
using DevExpress.LookAndFeel;
using DevExpress.UserSkins;
using DevExpress.XtraEditors;


namespace DxScheduleNaviForm
{
    public partial class Form1 : XtraForm
    {
        public Form1()
        {
            InitializeComponent();
            InitTreeListControl();


        }
        void InitTreeListControl()
        {
            Projects projects = InitData();
            DataBinding(projects);
        }
        Projects InitData()
        {
            Projects projects = new Projects();
            projects.Add(new Project("Project A", false));
            projects.Add(new Project("Project B", false));
            projects[0].Projects.Add(new Project("Task 1", true));
            projects[0].Projects.Add(new Project("Task 2", true));
            projects[0].Projects.Add(new Project("Task 3", true));
            projects[0].Projects.Add(new Project("Task 4", true));
            projects[1].Projects.Add(new Project("Task 1", true));
            projects[1].Projects.Add(new Project("Task 2", true));
            return projects;
        }
        void DataBinding(Projects projects)
        {
            treeList.ExpandAll();
            treeList.DataSource = projects;
            treeList.BestFitColumns();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'myStockDataSet.ScheduleLogX' table. You can move, or remove it, as needed.
            this.scheduleLogXTableAdapter.Fill(this.myStockDataSet.ScheduleLogX);

        }

        private void schedulerStorage1_AppointmentsCUID(object sender, DevExpress.XtraScheduler.PersistentObjectsEventArgs e)
        {
            scheduleLogXTableAdapter.Update(myStockDataSet);
            myStockDataSet.AcceptChanges();
            
        }


    }
}